<template>
  <div class="worker-training">
    <Box title="工人培训">
      <div class="main">
        <div class="item">
          <img src="@/assets/longscreen3/worker_1.png" alt="" class="img" />
          <p class="key">累计培训</p>
          <div class="data">
            <count-to
              class="val"
              :startVal="0"
              :endVal="trainCount"
              :duration="1000"
            ></count-to>
            <span class="unit">次</span>
          </div>
        </div>
        <div class="item">
          <img src="@/assets/longscreen3/worker_2.png" alt="" class="img" />
          <p class="key">颁发电子证件</p>
          <div class="data">
            <count-to
              class="val"
              :startVal="0"
              :endVal="holdCount"
              :duration="1000"
            ></count-to>
            <span class="unit">本</span>
          </div>
        </div>
        <div class="item">
          <img src="@/assets/longscreen3/worker_3.png" alt="" class="img" />
          <p class="key">累计开展培训</p>
          <div class="data">
            <count-to
              class="val"
              :startVal="0"
              :endVal="productCount"
              :duration="1000"
            ></count-to>
            <span class="unit">场</span>
          </div>
        </div>
      </div>
    </Box>
  </div>
</template>
  
<script setup>
import Box from "./box.vue";
import { ref, onMounted } from "vue";
import CountTo from "@/components/vueCountTo/vue-countTo.vue";
import { ajax } from "@/store/service";

const trainCount = ref(0);
const holdCount = ref(0);
const productCount = ref(0);

const init = async () => {
  const [res] = await ajax.training();
  trainCount.value=res.trainCount
  holdCount.value=res.holdCount
  productCount.value=res.productCount
};

onMounted(() => {
  init();
});
</script>

<style scoped lang='scss'>
.worker-training {
  .main {
    height: 382px;
    display: flex;
    align-items: center;
    justify-content: center;
    .item {
      width: 180px;
      height: 329px;
      background: linear-gradient(
        90deg,
        rgba(44, 64, 107, 0.08) 0%,
        rgba(44, 64, 107, 0.18) 100%
      );
      display: flex;
      flex-direction: column;
      padding-top: 50px;
      box-sizing: border-box;
      // justify-content: center;
      align-items: center;
      &:not(:last-child) {
        margin-right: 12px;
      }
      .img {
        width: 120px;
        height: 120px;
        margin-bottom: 28px;
      }
      .key {
        font-family: SourceHanSansCN, SourceHanSansCN;
        font-weight: bold;
        font-size: 18px;
        color: #c1ddff;
        line-height: 27px;
        letter-spacing: 1px;
        text-align: left;
        font-style: normal;
        margin-bottom: 17px;
      }
      .data {
        .val {
          font-family: PingFangSC, PingFang SC;
          font-weight: 600;
          font-size: 26px;
          color: #ffffff;
          line-height: 26px;
          text-shadow: 0px 0px 7px rgba(53, 101, 223, 0.82);
          text-align: center;
          font-style: normal;
        }
        .unit {
          font-family: SourceHanSansCN, SourceHanSansCN;
          font-weight: 400;
          font-size: 18px;
          color: #c1ddff;
          line-height: 27px;
          text-align: center;
          font-style: normal;
          margin-left: 8px;
        }
      }
    }
  }
}
</style>